package top.code.user.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.code.common.utils.SecurityUtils;
import top.code.user.dao.UserMapper;
import top.code.user.entity.User;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

/**
 * Created by setsun on 2017/9/21.
 */
@Service("userServiceImpl")
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;

    /**
    *@Author benson {www.honey520.com}
    *@Date 2017/9/21 21:06
    *@Description 根据用户查询用户名
    */
    @Override
    public User findUserByUserName(String username) {
       User user = userMapper.selectByUserName(username);
        return user;
    }


    @Override
    public void createUser(User user) throws UnsupportedEncodingException, NoSuchAlgorithmException {
            user.setPassword(SecurityUtils.encrptyPassword(user.getPassword()));
            userMapper.insertSelective(user);


    }
}
